﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");

		termId = event.getArg("TermID", event.getArg("TID"));
		termstart = event.getArg("DateStart");
		
		/* 学籍相关信息 */
		studentId = sessionAdvice.getAutherUserID();

		if ( len(studentId) and len(termId) ) {
			
			/*期末提前考试任务*/
		    sql = "select a.*, d.course_name, c.tch_name,d.course_credit,e.classroom,b.task_chooesd 
				    from t_new_examtaskAdvice a 
				    INNER JOIN t_task b on b.tsk_id = a.task_id 
				    INNER JOIN t_teacher c ON c.tch_id = b.tch_id 
				    INNER JOIN t_course d ON d.cid = b.cid 
				    INNER JOIN t_classroom e ON e.cr_id = a.cr_id 
				    where a.is_arranged = '3' 
				    AND b.term_id = :termId 
				    AND EXISTS(
						SELECT 1 FROM t_new_examadvice_student f WHERE f.task_id = a.task_id AND f.stu_id = :studentId
					)
				    order by e.classroom, a.date_exam, a.time_start"; 
		    
		    queryObj = new query( datasource=application.dnsSlave );
		    
		    queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="studentId", value=studentId, cfsqltype="cf_sql_varchar" );
		    
		    rs_examTaskAdvice = queryObj.execute( sql=sql ).getResult();
			
			/*期末考试任务*/
			sql = "select a.*, c.tch_name, d.course_name,d.course_credit,e.classroom,b.task_chooesd 
					from t_new_examtask a 
					INNER JOIN t_task b on b.tsk_id = a.task_id 
					INNER JOIN t_teacher c ON c.tch_id = b.tch_id 
					INNER JOIN t_course d ON d.cid = b.cid 
					INNER JOIN t_classroom e ON e.cr_id = a.cr_id 
					where a.is_arranged = '3' 
					AND b.term_id = :termId 
					AND EXISTS(
						SELECT 1 FROM t_student_course f WHERE f.task_id = a.task_id AND f.stu_id = :studentId
					)
					order by a.date_exam,a.time_start"; 
			
			queryObj = new query( datasource=application.dnsSlave );
			
		
			queryObj = new Query( datasource=application.dnsSlave );
			queryObj.addParam( name="termId", value=termId, cfsqltype="cf_sql_char" );
			queryObj.addParam( name="studentId", value=studentId, cfsqltype="cf_sql_varchar" );

			rs_exam = queryObj.execute( sql=sql ).getResult();
		}

	</cfscript>	
</cfsilent>

<cfif rs_exam.recordCount or rs_examTaskAdvice.recordCount>
	<table class="UIEditable">
		<thead>
			<tr>
				<td width="25"></td>
                     <td>课程</td>
                     <td >考场</td>
                     <td>考试日期</td>
                     <td>考试时间</td>
                     <td>类型</td>
                     <td >教师</td>
                     
			</tr>
		</thead>
		<tbody>
          	 <cfset row = 0 />
          	<cfloop query="rs_examTaskAdvice" >
				<cfset row ++ />
                    <tr class="editRows">
                            <td class="index"><cfoutput>#row#</cfoutput></td>
                            <td><cfoutput>#rs_examTaskAdvice.course_name#</cfoutput></td>
                            
                            <td><cfoutput>#rs_examTaskAdvice.classroom#</cfoutput></td>
                            <td><cfoutput>#datetimeAdvice.formatDateString( rs_examTaskAdvice.date_exam )#</cfoutput></td>
                            <td><cfoutput>#datetimeAdvice.formatTimeString(rs_examTaskAdvice.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString(rs_examTaskAdvice.time_end, 'HH:MI')#</cfoutput></td>
                             <td><span style="color:#F0F">提前考试</span></td>
                          <td><cfoutput>#rs_examTaskAdvice.tch_name#</cfoutput></td>
                           
                     </tr>
               </cfloop>
                   
			<cfset row = 0 />
			<cfloop query="rs_exam">
				<cfset row++ />
				<tr class="editRows">
					  
                            <td class="index"><cfoutput>#row#</cfoutput></td>
                            <td><cfoutput>#rs_exam.course_name#</cfoutput></td>
                            <td><cfoutput>#rs_exam.classroom#</cfoutput></td>
                            <td><cfoutput>#datetimeAdvice.formatDateString( rs_exam.date_exam )#</cfoutput></td>
                            <td><cfoutput>#datetimeAdvice.formatTimeString(rs_exam.time_start, 'HH:MI')#</cfoutput> ~ <cfoutput>#datetimeAdvice.formatTimeString(rs_exam.time_end, 'HH:MI')#</cfoutput></td>
                            <td>正常考试</td>
                            <td><cfoutput>#rs_exam.tch_name#</cfoutput></td>
                           
				</tr>
			</cfloop>
		</tbody>	
	</table>
	<cfelse>
	<div class="systemNotice">
		<h3>目前期末考试安排还未发布</h3>
	</div>
</cfif>